package ua.epam.muzalevskiy.traction.dao;

import java.util.List;
import ua.epam.muzalevskiy.traction.dao.exceptions.NotExistsParameterException;
import ua.epam.muzalevskiy.traction.dao.exceptions.NotUniqueParameterException;
import ua.epam.muzalevskiy.traction.user.AuthorizedUser;
import ua.epam.muzalevskiy.traction.user.User;

/**
 * This interface defines methods that needed to select, insert, update, delete
 * data from DataBase.
 *
 * @author Muzalevskiy Vitaliy
 */
public interface UserDao {

    /**
     * Current method need to add User information to DataBase.
     *
     * @param user <code>AutorizedUser</code> type value that added 
     *      to DataBase.
     * @throws NotUniqueParameterException if user with such 
     *      parameters already exists in DataBese.
     */
    void addUser(User user) throws NotUniqueParameterException;

    /**
     * Method returns all users in DataBase.
     *
     * @return <code>List</code> type value that include all users
     *      from DataBase.
     */
    List<User> selectAll();

    /**
     * Method need to get user with concrete ID that get as parameter. 
     *
     * @param userID - ID of needed administrator.
     * @return <code>AutorizedUser</code> if it exist in DataBase.
     */
    AuthorizedUser selectUserByID(int userID);

    /**
     * Method need to get user with concrete login value that 
     * get as parameter.
     *
     * @param userName - login value of needed user.
     * @return <code>AutorizedUser</code> if it exist in DataBase.
     */
    AuthorizedUser selectUserByName(String userName);

    /**
     * Method need to get user with concrete email value that 
     * get as parameter.
     *
     * @param email - email value of needed user.
     * @return <code>AutorizedUser</code> if it exist in DataBase.
     */
    AuthorizedUser selectUserByEmail(String user);

    /**
     * Method need to delete user with concrete ID that get as parameter. 
     *
     * @param userID - ID of needed user.
     * @throws NotExistsParameterException if there is no user with
     *      such ID in DataBase.
     */
    void deleteUserByID(int userID) throws NotExistsParameterException;

    /**
     * Method need for logging of user with concrete login and password 
     * values that get as parameters.
     *
     * @param userName - login value of needed user.
     * @param userPassword - password value of needed user.
     * @return <code>AutorizedUser</code> value.
     * @throws NotExistsParameterException if user with such login
     *      does not exists in DataBase or if wrong password was entered.
     */
    AuthorizedUser getUser(String userName, String userPassword) 
            throws NotExistsParameterException;
}
